﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;

namespace Wpf.CommonTools.Converter
{
    public class EnumFlagToCollapsedConverter : IValueConverter
    {
        #region IValueConverter 成员

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (DesignerProperties.GetIsInDesignMode(new DependencyObject()))
            {
                return Visibility.Visible;
            }
            else
            {
                int a = System.Convert.ToInt32(value);
                int b = System.Convert.ToInt32(parameter);
                Visibility v = (a & b) == 0 && (a != b)
                    ? Visibility.Visible
                    : Visibility.Collapsed;
                return v;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
